export function reset (state) {
  state.fields = { host: [], build: [] }
  state.build = {items: [], value: null}
  state.host = {items: [], value: null}
}

export function saveSuccess (state) {
  state.loading.hide()
  state.opened = false
}

export function saveFail (state, payload) {
  state.opened = false
  state.loading.hide()
}

export function loadPackageSuccess (state, payload) {
  state.fields.build = []
  state.build = {items: [{ text: '', value: '' }]}
  let res = JSON.parse(payload)
  state.build.items = res.data
}

export function loadHostSuccess (state, payload) {
  state.fields.host = []
  state.host = {items: [{ text: '', value: '' }]}
  let res = JSON.parse(payload)
  for (let i in res.data) {
    res.data[i].avatar = '/statics/' + res.data[i].avatar + '.png'
  }
  state.host.items = res.data
}
